Skip to contents

Applies a function to one stored argument. When the argument is stored as a model_spec, fn can change it with the term helpers.

Usage

modify_arg(spec, name, fn)

Arguments

spec

A model_spec object.

name

Character string naming the argument to modify.

fn

A function of one argument, applied to the stored value; its return value replaces it.

Value

A new model_spec with the argument replaced.

See also

Examples

m <- model_spec(x1, x2) |> set_args(nominal = model_spec(x1))
modify_arg(m, "nominal", \(a) add_terms(a, x2))
#> model_spec: ~ x1 + x2 
#>   args: nominal = ~ x1 + x2